package client.communication.listeners;

import client.Client;
import message.AuthenticationRequestMessage;
import message.AuthenticationResponseMessage;
import message.Message;
import communication.MessageListener;
import communication.MessageReceivedEvent;
import components.AuthenticationContentPanel;

public class AuthenticationListener implements MessageListener
{
	private final Client client;
	
	public AuthenticationListener(Client client)
	{
		this.client = client;
	}
	@Override
	public void messageRecieved(MessageReceivedEvent e)
	{
		AuthenticationResponseMessage message = (AuthenticationResponseMessage) e.getMessage();		
	
		System.out.println(message.isSuccess());
		
		if (message.isSuccess())
			client.setStatusText("Authentication successful");
		else
			client.setStatusText("Authentication failed");
	}

	@Override
	public boolean acceptsMessage(Message message)
	{
		return message.getClass().equals(AuthenticationResponseMessage.class);
	}

}
